﻿@model IEnumerable<MvcShopping.Models.ProductCategory>
@{Layout = null;}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Thirteen Shop后台管理</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />

    <link rel="stylesheet" href="~/tpl/static/css/bootstrap.min.css" type="text/css" media="all" />
    <link rel="stylesheet" href="~/tpl/static/css/jquery-ui.min.css" type="text/css" media="all" />
    <link rel="stylesheet" href="~/tpl/Admin/common/css/admin.css" type="text/css" />
    <link href="~/Content/alert.css" rel="stylesheet" />
    <style>
        #Url {
            display: none;
        }
    </style>
</head>
<script type="text/javascript" src="~/tpl/static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="~/tpl/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="~/tpl/static/js/jquery.artDialog.js?skin=aero"></script>
<script type="text/javascript" src="~/tpl/static/js/iframeTools.js"></script>
<script type="text/javascript" src="~/tpl/static/js/jquery.form.min.js"></script>
<script type="text/javascript" src="~/tpl/static/js/jquery.validate.min.js"></script>
<script language="javascript" src="~/tpl/static/js/jquery.imagePreview.js"></script>
<script type="text/javascript" src="~/tpl/static/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="~/tpl/static/js/datepicker.js"></script>
<script type="text/javascript" src="~/tpl/Admin/common/js/common.js"></script>
<script src="~/Scripts/alert.js"></script>
<body>
    <!--顶部-->
    <nav class="navbar navbar-inverse">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="~/Home/index">Thirteen Shop后台管理</a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="~/Home/index" target="_blank"><i class="glyphicon glyphicon-home"></i> 网站首页</a>
                    </li>

                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="glyphicon glyphicon-user"></i> 超级管理员【admin】 <span class="caret"></span></a>
                        <ul class="dropdown-menu" role="menu">
                            
                            <li>
                                <a href="">退出</a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
    <!--顶部结束-->
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-2">
                <div id="nav">
                    <p id="p_home"><i class="glyphicon glyphicon-home"></i> 首页</p>
                    <p id="p_article"><i class="glyphicon glyphicon-list-alt"></i> 商品管理</p>
                    <div class="menu_body" id="b_article">
                        <li>
                            <a href="~/Admin/Add"><i class="glyphicon glyphicon-menu-right"></i> 添加商品</a>
                        </li>
                        <li>
                            <a href="~/Admin/index"><i class="glyphicon glyphicon-menu-right"></i> 商品列表</a>
                        </li>
                    </div>

                    <p id="p_user"><i class="glyphicon glyphicon-user"></i> 用户管理</p>
                    <div class="menu_body" id="b_user">
                        <li>
                            <a href="~/AdminMember/Add"><i class="glyphicon glyphicon-menu-right"></i> 添加用户</a>
                        </li>
                        <li>
                            <a href="~/AdminMember/index"><i class="glyphicon glyphicon-menu-right"></i> 用户列表</a>
                        </li>
                    </div>
                    <p id="p_sys"><i class="glyphicon glyphicon-adjust"></i> 类别管理</p>
                    <div class="menu_body" id="b_sys">
                        <li>

                            <a href="~/ProductCategories/Create">查看与添加</a>
                        </li>
                        
                    </div>

                    <p id="p_sys"><i class="glyphicon glyphicon-cog"></i> 订单管理</p>
                    <div class="menu_body" id="b_sys">
                        <li>
                            <a href="~/Admin/AdminOrder">查看订单</a>
                        </li>

                    </div>

                    <p id="p_sys"><i class="glyphicon glyphicon-cog"></i> 日志管理</p>
                    <div class="menu_body" id="b_logs">
                        <li>
                            <a href="~/Logs/Index">查看日志</a>
                        </li>

                    </div>
                </div>
            </div>

            <div class="col-md-10">


                <script type="text/javascript">
        $(document).ready(function () {
            $(".preview").preview();
        });

        function jumpUrl() {
            v = document.getElementById("path").options[document.getElementById("path").selectedIndex].value;
            url = "/index.php?g=admin&m=article&a=index&path=" + v;
            window.location.href = url;
        }
                </script>

                <ol class="breadcrumb">
                    <li>
                        <a href="javascript:;">类别管理</a>
                    </li>
                    <li class="active">查看与添加</li>
                </ol>

                <div class="col-md-10">
                    <h4>已有商品类别</h4>
                    <hr />
                    <table class="table">
                        <tr>
                            <th>序号</th>
                            <th>
                                @Html.DisplayNameFor(model => model.Name)
                            </th>
                            <th>
                                已有商品数目
                            </th>
                            <th>相关操作</th>
                        </tr>

                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>@item.Id</td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Name)
                                </td>
                                <td>
                                    @item.Products.Count() 种
                                </td>
                                <td>
                                    <a href="javascript:;" data-toggle="modal" class="updateType" data-id="@item.Id" data-name="@item.Name" data-target="#myModal">
                                        修改
                                    </a> |
                                    <a href="~/Home/ProductList/@item.Id">详情</a> |
                                    <a href="javascript:;" class="deleteGood" data-id="@item.Id">删除</a>
                                    
                                </td>
                            </tr>
                        }

                    </table>
                    
                    <div class="col-md-12" style="height:30px;"></div>
                    <form action="~/ProductCategories/Createa" method="post">

                        @Html.AntiForgeryToken()

                        <div class="form-horizontal">
                            <h4>新增商品类别</h4>
                            <hr />
                            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                            <div class="form-group">
                                <label class="control-label col-md-2">新增类名</label>

                                <div class="col-md-10">
                                    <input type="text" name="name" class="form-control" required />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-md-offset-2 col-md-10">
                                    <input type="submit" value="添加" class="btn btn-default" />
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <script type="text/javascript">
                    $("#path").val("");
                </script>

                <input type="hidden" id="menu_action" value="article" />
            </div>
        </div>

    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">修改类别名</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form" action="~/ProductCategories/Updatea" method="post">
                        <div class="form-group">
                            <label for="wsc-username" class="col-sm-2 control-label">原名：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" disabled id="beforeName" value="" required />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="afterName" class="col-sm-2 control-label">修改为：</label>
                            <div class="col-sm-10">
                                <input type="text" style="display:none" name="id" id="setId" />
                                <input type="text" class="form-control" name="name" id="afterName" required placeholder="请输入新名字" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-6 text-center">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            </div>
                            <div class="col-sm-6 text-center">
                                <button type="submit" onclick="saveUserInfo()" class="btn btn-danger">确认</button>
                            </div>
                        </div>
                    </form>
                </div>


            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <script type="text/javascript">
                    var M = {};
                    $(".deleteGood").each(function (index, value) {
                        $(this).click(function () {

                            var getid = parseInt($(this).attr('data-id'));
                            var a = index;
                        if (M.dialog7) {
                            return M.dialog7.show();
                        }
                        M.dialog7 = jqueryAlert({

                            'style': 'pc',
                            'title': '提示',
                            'content': "<p style='padd-left:100px;'>该操作是不可逆转的，删除后将无法找回，您已确认删除吗</p>",
                            'modal': true,
                            'contentTextAlign': 'left',
                            'width': '300',
                            'height': '150',
                            'animateType': 'linear',
                            'buttons': {
                                '确定': function () {
                                    $.ajax({
                                        url: 'deleteType',
                                        data: { id: getid },
                                        success: function () {
                                            $(".trFather").eq(a).remove();
                                            M.dialog7.close();
                                            if (M.dialog51) {
                                                return M.dialog51.show();
                                            }
                                            M.dialog51 = jqueryAlert({
                                                'content': '删除成功',
                                                'icon': '~/images/alert/right.png'
                                            });
                                           
                                        },
                                        error: function () {
                                            alert("服务器连接异常");
                                            M.dialog7.close();
                                        }
                                    });

                                },
                                '取消': function () {
                                    M.dialog7.close();
                                    if (M.dialog51) {
                                        return M.dialog51.show();
                                    }
                                    M.dialog51 = jqueryAlert({
                                        'content': '删除失败'
                                        
                                    })
                                }
                            }
                        });
                        //$.ajax({
                        //    url: "changeToAsp",
                        //    data: { Content: getid},
                        //    cache: false,
                        //    type: 'post',
                        //    datatype;"json",
                        //    success: function (data) {
                        //       // alert(data);

                        //    },
                        //    error: function (data) {
                        //        alert("服务器连接异常");
                        //    }
                        //});
                        });
                    });
                    $(".updateType").click(function () {
                        $('#beforeName').val($(this).attr('data-name'));
                        $("#setId").val($(this).attr("data-id"));
                    });
            $(document).ready(function () {
                //幻灯片元素与类“menu_body”段与类“menu_head”时点击
                var menu_action = $("#menu_action").val();
                $("#p_" + menu_action).addClass("select");
                $("#b_" + menu_action).show().addClass("local");

                $("#nav p").click(function () {
                    $(this).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
                    $("#nav p").removeClass("select");
                    $(this).addClass("select");
                    $(this).next("div.menu_body").addClass("local");
                });

                $("#picname_src").click(function () {
                    $("#picname").click();
                    $("#Url").val($("#picname").val());
                })
            });
    </script>

</body>

</html>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}


